package com.gratuity.widget;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class MainActivity extends Activity {
	public static String AMOUNT_WIDGET_RECEIVER = "AmountReceiverWidget";
	public static String TIP_WIDGET_RECEIVER = "TipReceiverWidget";	
	public static String SPLIT_WIDGET_RECEIVER = "SplitReceiverWidget";
	public static int i = 0;
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
		//Tip Action
	if (getIntent().getAction().equals(TIP_WIDGET_RECEIVER)) {
		String msg = "null";
		try {
		msg = getIntent().getStringExtra("msg");
		} catch (NullPointerException e) {
		Log.e("Error", "msg = null");
		}
		final CharSequence[] items = {"10%", "15%", "20%", "25%"};

		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("Pick a color");
		builder.setItems(items, new DialogInterface.OnClickListener() {
		    public void onClick(DialogInterface dialog, int item) {
		        i=item;
		    }
		});
		AlertDialog alert = builder.create();
		Toast.makeText(this, items[i], Toast.LENGTH_SHORT).show();
	} 
	}
}
